home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 001-025 / disk_023 / ver30 / tty / atari / tty.c next >
C/C++ Source or Header  |  1992-05-06  |  3KB  |  196 lines

  1. /*
  2.  * Name:    MicroEMACS
  3.  *        Atari 520ST terminal.
  4.  * Version:    30
  5.  * Last edit:    22-Feb-86
  6.  * By:        rex::conroy
  7.  *        decvax!decwrl!dec-rhea!dec-rex!conroy
  8.  *
  9.  * This code simulates scrolling regions by using the
  10.  * insert line and delete line functions. Should display
  11.  * handling be taught about this. Based on Rich's code
  12.  * for the Heath H19.
  13.  */
  14. #include    "def.h"
  15.  
  16. #define    BEL    0x07            /* BEL character.        */
  17. #define    ESC    0x1B            /* ESC character.        */
  18. #define    LF    0x0A            /* Line feed.            */
  19.  
  20. extern    int    ttrow;
  21. extern    int    ttcol;
  22. extern    int    tttop;
  23. extern    int    ttbot;
  24. extern    int    tthue;
  25.  
  26. int    tceeol    =    2;        /* Costs.            */
  27. int    tcinsl    =    11;
  28. int    tcdell    =    11;
  29.  
  30. /*
  31.  * No-op.
  32.  */
  33. ttinit()
  34. {
  35. }
  36.  
  37. /*
  38.  * No-op.
  39.  */
  40. tttidy()
  41. {
  42. }
  43.  
  44. /*
  45.  * Move the cursor to the specified
  46.  * origin 0 row and column position. Try to
  47.  * optimize out extra moves; redisplay may
  48.  * have left the cursor in the right location
  49.  * on the screen last time.
  50.  */
  51. ttmove(row, col)
  52. {
  53.     if (ttrow!=row || ttcol!=col) {
  54.         if (row > nrow)
  55.             row = nrow;
  56.         if (col > ncol)
  57.             col = ncol;
  58.         ttputc(ESC);
  59.         ttputc('Y');
  60.         ttputc(row+' ');
  61.         ttputc(col+' ');
  62.         ttrow = row;
  63.         ttcol = col;
  64.     }
  65. }
  66.  
  67. /*
  68.  * Erase to end of line.
  69.  */
  70. tteeol()
  71. {
  72.     ttputc(ESC);
  73.     ttputc('K');
  74. }
  75.  
  76. /*
  77.  * Erase to end of page.
  78.  */
  79. tteeop()
  80. {
  81.     ttputc(ESC);
  82.     ttputc('J');
  83. }
  84.  
  85. /*
  86.  * Make a noise.
  87.  */
  88. ttbeep()
  89. {
  90.     ttputc(BEL);
  91.     ttflush();
  92. }
  93.  
  94. /*
  95.  * Insert nchunk blank line(s) onto the
  96.  * screen, scrolling the last line on the
  97.  * screen off the bottom. This is done with
  98.  * a cluster of clever insert and delete commands,
  99.  * because there are no scroll regions.
  100.  */
  101. ttinsl(row, bot, nchunk)
  102. {
  103.     register int    i;
  104.  
  105.     if (row == bot) {
  106.         ttmove(row, 0);
  107.         tteeol();
  108.         return;
  109.     }
  110.     ttmove(1+bot-nchunk, 0);
  111.     for (i=0; i<nchunk; i++) {
  112.         ttputc(ESC);
  113.         ttputc('M');
  114.     }
  115.     ttmove(row, 0);
  116.     for (i=0; i<nchunk; i++) {
  117.         ttputc(ESC);
  118.         ttputc('L');
  119.     }
  120.     ttrow = row;
  121.     ttcol = 0;
  122. }
  123.  
  124. /*
  125.  * Delete nchunk line(s) "row", replacing the
  126.  * bottom line on the screen with a blank
  127.  * line. This is done with a crafty sequences
  128.  * of insert and delete line; there is no scroll
  129.  * region on the Heath. The presence of the
  130.  * echo area makes a boundry condition
  131.  * go away.
  132.  */
  133. ttdell(row, bot, nchunk)
  134. {
  135.     register int    i;
  136.  
  137.     if (row == bot) {
  138.         ttmove(row, 0);
  139.         tteeol();
  140.         return;
  141.     }
  142.     ttmove(row, 0);
  143.     for (i=0; i<nchunk; i++) {
  144.         ttputc(ESC);
  145.         ttputc('M');
  146.     }
  147.     ttmove(1+bot-nchunk,0);
  148.     for (i=0; i<nchunk; i++) {
  149.         ttputc(ESC);
  150.         ttputc('L');
  151.     }
  152.     ttrow = bot-nchunk;
  153.     ttcol = 0;
  154. }
  155.  
  156. /*
  157.  * No-op.
  158.  */
  159. ttwindow(top, bot)
  160. {
  161. }
  162.  
  163. /*
  164.  * No-op.
  165.  */
  166. ttnowindow()
  167. {
  168. }
  169.  
  170. /*
  171.  * Set display color on Heath. Normal
  172.  * video is text color. Reverse video is used for
  173.  * the mode line.
  174.  */
  175. ttcolor(color)
  176. register int    color;
  177. {
  178.     if (color != tthue) {
  179.         if (color == CTEXT) {        /* Normal video.    */
  180.             ttputc(ESC);
  181.             ttputc('q');
  182.         } else if (color == CMODE) {    /* Reverse video.    */
  183.             ttputc(ESC);
  184.             ttputc('p');
  185.         }
  186.         tthue = color;
  187.     }
  188. }
  189.  
  190. /*
  191.  * No-op.
  192.  */
  193. ttresize()
  194. {
  195. }
  196.